package com.huabo.system.service.impl;

import com.huabo.system.mysql.entity.TblAuditOptionMySql;
import com.huabo.system.mysql.mapper.TblAuditOptionMySqlMapper;
import com.huabo.system.oracle.entity.TblAuditOption;
import com.huabo.system.oracle.mapper.TblAuditOptionMapper;
import com.huabo.system.service.TblAuditOptionService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Service
public class TblAuditOptionServiceImpl implements TblAuditOptionService {

    @Resource
    private TblAuditOptionMapper tblAuditOptionMapper;

    @Resource
    private TblAuditOptionMySqlMapper tblAuditOptionMySqlMapper;

    @Override
    public List<TblAuditOption> findOptionByRelationId(BigDecimal planid) {
        return tblAuditOptionMapper.findOptionByRelationId(planid);

    }

    @Override
    public List<TblAuditOptionMySql> findOptionByMySqlRelationId(BigDecimal planid) {
        return tblAuditOptionMySqlMapper.findOptionByRelationId(planid);
    }

    @Override
    public List<TblAuditOption> findOptionByRelation(String sheetid, Integer cyid) {
        List<Object[]> list = this.tblAuditOptionMapper.OBJlistBySql(sheetid, cyid);

        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        List<TblAuditOption> aoList = new ArrayList();
        for (int i = 0; i < list.size(); ++i) {
            Object[] o = (Object[]) list.get(i);
            TblAuditOption ao = new TblAuditOption();
            //ao.setStaffidName(o[0].toString());该字段实体类与数据库均没有，也没有任何关联
            ao.setOptDesc(o[1].toString());
            ao.setOptState(o[2].toString());
            ao.setOptStaffid(new BigDecimal(o[3].toString()));

            try {
                if (o[4] != null && o[4] != "") {
                    String str2 = o[4].toString();
                    Date date = sdf.parse(str2);
                    ao.setCreateDate(date);
                }
            } catch (Exception var12) {
                var12.printStackTrace();
            }

            aoList.add(ao);
        }
        return aoList;
    }

    @Override
    public List<TblAuditOptionMySql> findOptionByMySqlRelation(String sheetid, Integer cyid) {
        List<Object[]> list = this.tblAuditOptionMySqlMapper.OBJlistBySql(sheetid, cyid);
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        List<TblAuditOptionMySql> aoList = new ArrayList();
        for (int i = 0; i < list.size(); ++i) {
            Object[] o = (Object[]) list.get(i);
            TblAuditOptionMySql ao = new TblAuditOptionMySql();
            //ao.setStaffidName(o[0].toString());该字段实体类与数据库均没有，也没有任何关联
            ao.setOptDesc(o[1].toString());
            ao.setOptState(o[2].toString());
            ao.setOptStaffid(new BigDecimal(o[3].toString()));

            try {
                if (o[4] != null && o[4] != "") {
                    String str2 = o[4].toString();
                    Date date = sdf.parse(str2);
                    ao.setCreateDate(date);
                }
            } catch (Exception var12) {
                var12.printStackTrace();
            }

            aoList.add(ao);
        }
        return aoList;
    }
}
